package org.gdsdxy.pmmp.test;

import org.gdsdxy.pmmp.dao.IUserManagerDao;
import org.gdsdxy.pmmp.dao.UserManagerDaoImpl;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class DaoFactory {
	public IUserManagerDao getDao(String impl){
		if("jdbc".equals(impl)){
			return new UserManagerDaoImpl();
		}else if("spring".equals(impl)){
			ApplicationContext ac = new ClassPathXmlApplicationContext("applicationContext.xml");
			return (IUserManagerDao) ac.getBean("dao");
		}else{
			return null;
		}
	}
	
	public static void main(String[] args) {
		DaoFactory factory = new DaoFactory();
		IUserManagerDao dao = factory.getDao("jdbc");
		System.out.println(dao);
	}
}
